﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using Kaiser.Models;
using Kaiser.Models.SearchModels;
using Kaiser.Modules.Admin.Repositories;
using Kaiser.Repositories;

namespace Kaiser.Services.Impl
{
    public class AttachService : IAttachService
    {
        public void Insert(Models.Attach model)
        {
            try
            {
                DependencyResolver.Current.GetService<IAttachRepository>().Insert(model);
            }
            catch (Exception)
            {
                throw;
            }
        }

        public void Update(Models.Attach model)
        {
            try
            {
                DependencyResolver.Current.GetService<IAttachRepository>().Update(model);
            }
            catch (Exception)
            {
                throw;
            }
        }

        public int Delete(object primaryId)
        {
            try
            {
                return DependencyResolver.Current.GetService<IAttachRepository>().DeleteList(new List<string>(new string[] { primaryId.ToString() }));
            }
            catch (Exception)
            {
                throw;
            }
        }

        public int DeleteList(IList<string> ids)
        {
            try
            {
                return DependencyResolver.Current.GetService<IAttachRepository>().DeleteList(ids);
            }
            catch (Exception)
            {
                throw;
            }
        }

        public Models.Attach Get(object primaryId)
        {
            try
            {
                return DependencyResolver.Current.GetService<IAttachRepository>().Get(primaryId);
            }
            catch (Exception)
            {
                throw;
            }
        }

        public DataGrid<Attach> SearchAttach(AttachSearch search, PagingInfo pageinfo)
        {
            try
            {
                return DependencyResolver.Current.GetService<IAttachRepository>().SearchAttach(search, pageinfo);
            }
            catch (Exception)
            {
                throw;
            }
        }
    }
}
